package hello;

import java.util.Arrays;

public class Case6 {
    public static void main(String[] args) {
        //正序
        int[] arr1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        Arrays.sort(arr1);
        for (int i = 0; i < arr1.length; i++) {
            System.out.println(arr1[i]);
        }
        //倒序
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        Case6 cc = new Case6();
        cc.sort(arr);

    }

    public void sort(int[] arr) {
        System.out.println("数组的原有内容:");
        showArray(arr);
        int temp;
        int len = arr.length;
        for (int i = 0; i < len / 2; i++) {
            temp = arr[i];
            arr[i] = arr[len - 1 - i];
            arr[len - 1 - i] = temp;
        }
        System.out.println("反转排序后的：");
        showArray(arr);
    }

    public void showArray(int[] arr) {
        for (int x : arr) {
            System.out.println(x);
        }

    }
}
